import { Component,ViewChild} from '@angular/core';
import {Tabs,App,Platform} from 'ionic-angular'
import { AboutPage } from '../about/about';
import { ContactPage } from '../contact/contact';
import { HomePage } from '../home/home';
import {MyProvider} from "../../providers/my/my";

@Component({
  templateUrl: 'tabs.html'
})
export class TabsPage {

  tab1Root = HomePage;
  tab2Root = AboutPage;
  tab3Root = ContactPage;

  //通过JS控制选项
  @ViewChild('tabs') tabRef:Tabs;
  ionViewDidEnter() {
      if(!this.myService.orderTab){
        this.myService.orderTab = this.myService.tabBroadcast.asObservable().subscribe(id=>{
          this.app.getRootNavs()[0].push(TabsPage);
        });
      }
  }

  switchTabs(id:number){
    return this.tabRef.select(id);
  }

  isAndroid;
  constructor(public app:App,public myService:MyProvider,platform: Platform) {
    this.isAndroid = platform.is('android');
  }
}
